﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace FixEngine
{
    [Serializable]
    public abstract class Fix42MessageBase : IMessage, ISerializable
    {
        #region IMessage Members

        public FixVersion Version
        {
            get { return FixVersion.Fix42; }
        }

        public abstract Category Category { get; }

        public abstract short MessageID{ get; }

        public abstract string MessageType { get; }

        public abstract Section SectionType { get; }

        protected List<IField> _fields;
        public List<IField> Content
        {
            get 
            { 
                return _fields; 
            }
        }
        #endregion

        #region ISerializable Members

        public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("35", this.MessageType);
            foreach (IField field in Content)
            {
                info.AddValue(field.TagID.ToString(), field.Value);
            }
        }

        #endregion
    }
}
